//
//  CouponsCell.m
//  HMMarket
//
//  Created by 孙鹏飞 on 2017/6/14.
//  Copyright © 2017年 homai. All rights reserved.
//

#import "CouponsCell.h"
#import "CouponModel.h"

@interface CouponsCell()

@property (weak, nonatomic) IBOutlet UIImageView *iconImage;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *rangeLabel;
@property (weak, nonatomic) IBOutlet UILabel *typeLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *outTimeLabel;

@end

@implementation CouponsCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString * ID = @"coupons";
    CouponsCell * cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
    }
    // 取消cell选中的颜色
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)setDetail:(CouponDetail *)detail
{
    _detail = detail;
    NSLog(@"%@",_detail.status);
    
    if ([_detail.status isEqualToString:@"0"]) {
        self.iconImage.image = [UIImage imageNamed:@"ticket_bg4"];
        self.outTimeLabel.hidden = YES;
    } else if ([_detail.status isEqualToString:@"2"]) {
        self.iconImage.image = [UIImage imageNamed:@"ticket_bg3"];
        self.outTimeLabel.hidden = NO;
    }
    
    self.priceLabel.text = _detail.price;
    self.rangeLabel.text = _detail.range;
    self.typeLabel.text = _detail.type;
    self.descLabel.text = _detail.desc;
    self.timeLabel.text = [NSString stringWithFormat:@"有效期：%@-%@",_detail.start_time,_detail.end_time];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
